[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
forward                  Subprogram Modifier for Forward Declarations

 procedure <pname>(<parameters>); forward;
 function  <fname>(<parameters>) : <ftype>; forward;

    Occasionally, you may need to have two subprograms (procedures and
    functions) call one another. However, Pascal requires that a
    subprogram be declared before it can be called. FORWARD declarations
    circumvent that restriction by allowing you to define a subprogram--
    give its name and parameters--at one spot in your program, then
    declaring it--give its actual code--later on.

  -------------------------------- Example ---------------------------------

    Suppose you have two subprograms, Fred and Jane, that call each other.
    Here's how you might set them up:

           procedure Fred(I,J : Integer; var X : Real); forward;

           function Jane(A,B,C : Real) : Integer;
           begin
             ...
             Fred(5,3,A);
             ...
           end; { of func Jane }

           procedure Fred;
           begin
             ...
             J := Jane(2.3,2.9,-0.5);
             ...
           end; { of proc Fred }

    The actual declaration of Fred has no parameters; those were already
    defined in the FORWARD declaration.

See Also: procedure function
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson